<template>
 <el-select v-model="valuetype"  @change="changetype">
    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
    </el-option>
</el-select>
</template>
<script>
const goodOptions = ["哇哈哈", "辣条", "矿泉水", "西瓜", "苹果"];
export default {
    data() {
        return {
            options: [
                    {
                        value: 'all',
                        label: '全部'
                    },
                    {
                        value: 'model',
                        label: '型号'
                    },
                    {
                        value: 'machine',
                        label: '机器'
                    }
                ],
            valuetype: 'all',
        };
    },
    methods: {
        handleAllChange(val) {
            console.log(val, "555");
            this.checkedGoods = val ? goodOptions : [];
            this.isIndeterminate = false;
            if (val) {
                this.getAllPrice();
            } else {
                this.allPrice = 0;
            }
        },
        handleOneChange(value) {
            let a = 0;
            let checkedCount = value.length;
            this.checkAll = checkedCount === this.checkedGoods.length;
            this.isIndeterminate = checkedCount > 0 && checkedCount < this.checkedGoods.length;
            value.filter((it, id) => {
                if (it == this.goods[id].name) {
                    if (this.goods[id].OnePrice) {
                        a += this.goods[id].OnePrice;
                    }
                }
            });
            this.allPrice = a;
        },
        handleChangeNum(val) {
            this.goods.filter((it, id) => {
                if (it.id == val) {
                    it.OnePrice = it.num * it.price;
                }
            });
            this.getAllPrice();
        },
        getAllPrice() {
            //获取总价方法封装
            let money = 0;
            this.goods.filter((it, id) => {
                if (it.OnePrice) {
                    money += it.OnePrice;
                }
            });
            this.allPrice = money;
        },
        submitBtn() {
            this.$alert( this.allPrice+"元", "所有商品总计",{
                confirmButtonText: "确定",
                callback: action => {
                    this.$message({
                        type: "info",
                        message: "哈哈哈"
                    });
                }
            });
        }
    }
};
</script>
<style lang="postcss" scoped>
.bbb {
    margin-left: 40px;
    margin-top: 80px;
}
.aaa > label {
    display: block;
    text-align: left;
    margin-top: 20px;
}
.el-checkbox {
    display: block;
    text-align: left;
}
</style>